<include file="Public/head"/>

<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>
            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="cf">
                            <form class="form-inline" action="" method="get">
                                <input type="hidden" name="m" value="Qwadmin"/>
                                <input type="hidden" name="c" value="Article"/>
                                <input type="hidden" name="a" value="index"/>
                                <a class="btn btn-info" href="{:U('add')}" value="">新增</a>
                                <label class="inline">所属分类</label>
                                <select name="cid" class="form-control">
                                    <option value="0">--分类--</option>
                                    <volist name="pcategory" id="val">
                                        <option value="{$val['id']}">{$val['title']}</option>
                                    </volist>
                                </select>
                                <label class="inline">产品标题</label>
                                <input type="text" name="keyword" value="{:I('keyword')}" class="form-control">

                                <label class="inline">&nbsp;&nbsp;产品排序：</label>
                                <select name="order" class="form-control">
                                    <option value="desc" <if condition="I('order') eq desc">selected</if>>发布时间降序</option>
                                    <option value="asc" <if condition="I('order') eq asc">selected</if> >发布时间升序</option>

                                </select>
                                <button type="submit" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    搜索
                                </button>
                            </form>
                        </div>
                        <div class="space-4"></div>
                        <form id="form" method="post" action="{:U('del')}">
                            <table class="table table-striped table-bordered">
                                <thead>
                                <tr>
                                    <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                    <th>所属分类</th>
                                    <th>产品标题</th>
                                    <th>产品型号</th>
                                    <th>产品规格</th>
                                    <th>产品用途</th>
                                    <th>产品形状</th>
                                    <th>发布状态</th>
                                    <th>发布时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="list" id="val">
                                    <tr>
                                        <td class="center"><input class="product_ids" type="checkbox" name="product_ids[]"
                                                                  value="{$val['id']}"></td>
                                        <td><a href="{:U('index',array('cid'=>$val['cid']))}" title="{$val['cate_name']}">{$val['cate_name']}</a>
                                        </td>
                                        <td>{$val['title']}</td>
                                        <td>{$val['xinghao']}</td>
                                        <td>{$val['guige']}</td>
                                        <td>{$val['yongtu']}</td>
                                        <td>{$val['xingzhuang']}</td>
                                        <td>
                                            <if condition="$val.ispushed eq 1">
                                                <span class="label label-sm label-info arrowed arrowed-righ">未发布</span>
                                            <else/>
                                                <span class="label label-sm label-success arrowed arrowed-righ">已发布</span>
                                            </if>
                                        </td>
                                        <td>{$val['ctime']}</td>
                                        <td><a href="{:U('edit',array('product_id'=>$val['product_id']))}"><i
                                                class="ace-icon fa fa-pencil bigger-100"></i>修改</a>
                                            &nbsp&nbsp;
                                            <if condition="$val.ispushed eq 0 ">
                                            <a href="{:U('change',array('product_id'=>$val['product_id'],'type'=>1))}"><i
                                                    class="ace-icon fa fa-pencil bigger-100"></i>隐藏</a>
                                            &nbsp&nbsp;
                                            </if>
                                            <if condition="$val.ispushed eq 1 ">
                                                <a href="{:U('change',array('product_id'=>$val['product_id'],'type'=>2))}"><i
                                                        class="ace-icon fa fa-pencil bigger-100"></i>发布</a>
                                                &nbsp&nbsp;
                                            </if>
                                            <a href="javascript:;" val="{:U('del',array('product_ids'=>$val['product_id']))}" class="del"><i
                                                class="ace-icon fa fa-trash-o bigger-100 red"></i>删除</a></td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                        </form>
                        <div class="cf">
                            <input id="submit" class="btn btn-info" type="button" value="删除">
                        </div>
                        {$page}
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".check-all").click(function () {
            $(".product_ids").prop("checked", this.checked);
        });
        $(".product_ids").click(function () {
            var option = $(".ids");
            option.each(function (i) {
                if (!this.checked) {
                    $(".check-all").prop("checked", false);
                    return false;
                } else {
                    $(".check-all").prop("checked", true);
                }
            });
        });
        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除所选产品？",
                callback: function (result) {
                    if (result) {
                        $("#form").submit();
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除该产品？",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    })

    //百度推送
    $(".pushagain").on("click",function () {
        var $data = $(this).data("product_id");
        $.ajax({
            type: "POST",
            url: "{:U('pushAgain')}",
            data: {
                product_id : $data
            },
            dataType:"json",

            success: function(data){
                //var data = eval(data);
                layer.alert(data.info, {
                    skin: 'layui-layer-lan'
                    ,closeBtn: 0
                });
                window.location.reload();
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败
                alert("status:"+XMLHttpRequest.status);
                alert("readyState:"+XMLHttpRequest.readyState);
                alert(textStatus);
            }
        });
    })

    function pushagain_fun() {
        $(".pushagain").each(function () {
            var $flag = $(this).data("flag");
            if($flag==1){
                $(this).hide();
            }
        })
    }pushagain_fun();

</script>
</body>
</html>
